package cn.yeziji.file.config;

import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 一级缓存配置
 *
 * @author gzkemays
 * @since 2022/11/11 12:45 PM
 */
@Configuration
public class CacheConfig {
  @Bean(name = "fileMd5")
  public Cache<String, String> fileMd5() {
    return Caffeine.newBuilder()
        // 初始的缓存空间大小
        .initialCapacity(50)
        // 缓存的最大条数
        .maximumSize(50000)
        .build();
  }

  @Bean(name = "fileCache")
  public Cache<String, Object> fileCache() {
    return Caffeine.newBuilder()
        // 初始的缓存空间大小
        .initialCapacity(50)
        // 缓存的最大条数
        .maximumSize(50000)
        .build();
  }
}
